#pragma once

#include <string>
#include <optional>
#include <memory>

#include "server/rtmp/amf0/amf0_inc.hpp"
#include "server/rtmp/rtmp_protocol/rtmp_define.hpp"

/*
The command structure from the client to the seerver is as follows:
The command structure from the client to the server is as follows:
+----------------+---------+---------------------------------------+
| Field Name 	 | Type    | Description 							|
+--------------- +---------+---------------------------------------+
| Command Name   | String  | Name of the command. Set to "connect".|
+----------------+---------+---------------------------------------+
| Transaction ID | Number  | Always set to 1.                      |
+----------------+---------+---------------------------------------+
| Command Object | Object  | Command information object which has  |
|                |         | the name-value pairs.                 |
+----------------+---------+---------------------------------------+
| Optional User  | Object | Any optional information              |
|     Arguments  |         |                                       |
+----------------+---------+---------------------------------------+


**/

namespace mms{
class RtmpMessage;
class RtmpConnectCommandMessage{
public:
    RtmpConnectCommandMessage();
    RtmpConnectCommandMessage(int32_t transaction_id, const std::string& tc_url,
        const std::string& page_url, const std::string& swf_url, const std::string& app);
    
    virtual ~RtmpConnectCommandMessage();

    int32_t decode(std::shared_ptr<RtmpMessage> rtmp_msg);
    std::shared_ptr<RtmpMessage> encode();
    int32_t size();

public:
    Amf0String command_name_;
    Amf0Number transaction_id_;
    Amf0Object command_object_;
    std::optional<Amf0Object> optional_user_args_;

    std::string tc_url_;
    std::string page_url_;
    std::string swf_url_;
    std::string app_;
};

} // namespace mms